# encoding: utf-8

'''提取各地区数据，转换成sum为1的概率模型'''

import pandas as pd
import numpy as np

def softmax(data):
    return data/sum(data)

# 提取各地区总的发病人数，转换成概率模型
def to_local_a_prob(source: pd.core.frame.DataFrame):
    s4 = source['2004年甲']
    s7 = source['2007年甲']
    s10 = source['2010年甲']
    s13 = source['2013年甲']
    s16 = source['2016年甲']

    s40 = s4['发病数.4'][1:]
    s70 = s7['发病数.4'][1:]
    s100 = s10['发病数.4'][1:]
    s130 = s13['发病数.4'][1:]
    s160 = s16['发病数.4'][1:]
    
    s4p = softmax(s40)
    s7p = softmax(s70)
    s10p = softmax(s100)
    s13p = softmax(s130)
    s16p = softmax(s160)
    A = pd.DataFrame({4: s4p, 7: s7p, 10: s10p, 13: s13p, 16:s16p})

    print(A.idxmax())
